package com.github.ilioili.justdoit.common.config;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by hantuo on 16/5/26.
 */
public class AppConfig {
    private static final String IS_FIRST_TIME = "IsFirstTime";
    private static final String IS_VIBRATE = "IsVibrate";
    private static final String IS_GESTURE_ON = "IsGestureOn";
    public static final String IS_SLIDE_DELETE_CONFIRMED = "IsSlideDeleteConfirmed";
    private static SharedPreferences sharedPreferences;

    public static void init(Context context) {
        sharedPreferences = context.getSharedPreferences("AppConfig", Context.MODE_PRIVATE);
    }

    //应用程序第一次打开
    public static boolean isFirstTime() {
        return sharedPreferences.getBoolean(IS_FIRST_TIME, true);
    }

    //应用程序第一次打开
    public static void setIsFirstTime(boolean isFirstTime) {
        sharedPreferences.edit().putBoolean(IS_FIRST_TIME, isFirstTime).apply();
    }

    //提醒时是否开启震动
    public static boolean isVibrateOn() {
        return sharedPreferences.getBoolean(IS_VIBRATE, true);
    }

    //提醒时是否开启震动
    public static void setVibrate(boolean vibrate) {
        sharedPreferences.edit().putBoolean(IS_VIBRATE, vibrate).apply();
    }

    //手势密码是否开启
    public static boolean isGestureOn() {
        return sharedPreferences.getBoolean(IS_GESTURE_ON, false);
    }

    //手势密码是否开启
    public static void setGesture(boolean gesture) {
        sharedPreferences.edit().putBoolean(IS_GESTURE_ON, gesture).apply();
    }

    //是否提示右滑条目完成
    public static boolean isSlideDeleteConfirmed() {
        return sharedPreferences.getBoolean(IS_SLIDE_DELETE_CONFIRMED, false);
    }

    //设置是否提示右滑条目完成
    public static void setSlideDeleteConfirmed(boolean gesture) {
        sharedPreferences.edit().putBoolean(IS_SLIDE_DELETE_CONFIRMED, gesture).apply();
    }

    public static void clear() {
        sharedPreferences.edit().clear().apply();
    }
}
